<?php // $this->load->view('layouts/_flash'); 
if(!empty($levels)){
$roomLevelAttrib[] ='choose level';
foreach($levels as $level){
	$roomLevelAttrib[$level->level_id] = strtoupper($level->level_code).' - '.$level->level_desc;
}
}else{
	$system_message = '<div class="notice">Please Add Levels Before adding subjects</div>';
	$roomLevelAttrib[''] = 'No levels set';
}
?>
<div class="row">
	<div>
		<h5>Search Subject</h5>
		<hr class="clearfix">
		<form action="<?=site_url();?>room_section_subject/subjects" method="POST">
		<div class="row">
			<div class="large-8 columns">
				<label>Subject Name:</label>
				<input type="text" name="search_strings[subj_desc]">
			</div>
			<div class="large-4 columns">
			  <?php
				  echo form_label('Grade Level :', 'grade_level_id');
				  echo form_dropdown('search_strings[grade_level_id]', $roomLevelAttrib, set_value('grade_level_id'));	
			  ?>
			</div>
		</div>
		<div class="input-block">
			<input type="submit" class="btn btn-small btn-success" name="search" value="search">
			<a href="<?php echo site_url('room_section_subject/add_subject'); ?>" class="btn btn-small btn-primary add">Add Subject</a>
		</div>
		</form>
	</div>
<?if(isset($system_message))echo $system_message;?>

	<?if(!empty($subjects)):?>
	<div>
	<h5>Subject</h5>
	<hr class="clearfix">
	<table class="table">
		<tr>
			<th>Subject ID</th>
			<th>Subject Code</th>
			<th>Subject Name</th>
			<th>Units</th>
			<th>Grade Level</th>
			<th>Edit Subject</th>
		</tr>
		<tbody>
		<?foreach($subjects as $subject):?>
			<tr>
				<td><?=$subject->subj_uniq_id;?></td>
				<td><?=$subject->subj_code;?></td>
				<td><?=$subject->subj_desc;?></td>
				<td><?=$subject->subj_units;?></td>
				<td><?=$subject->level_desc;?></td>
				<td><a href="<?php echo site_url('room_section_subject/edit_subject/'.$subject->subj_id)?>" class="btn btn-mini"><i class="icon-pencil"></i> Edit</a></td>
				<!--
				<td>
				<?php if($subject->subj_stat == 'active'):?>
				  <a href="<?php echo site_url($subject->subj_id)?>" class="btn btn-mini btn-primary confirm" title="Deactivate <?php echo $subject->subj_desc;?>">Deactivate
				<?php elseif($subject->subj_stat == 'inactive'): ?>
				  <a href="<?php echo site_url($subject->subj_id)?>" class="btn btn-mini btn-primary confirm" title="Activate <?php echo $subject->subj_desc;?>">Activate
				<?php endif; ?>
				</td>
				-->
			</tr>
		<?endforeach;?>
		</tbody>
		</table>
		</div>
	<?else:?>
		<div>
			<div class="alert-box info">No subject found.</div>
		</div>
	<?endif;?>
<?=$links;?>
</div>